#include "p18cxxx.h"
#include "hardware.h"
#include "mydelay.h"

char s0[] = {1,0,0,0,0,0,1,1};
char s1[] = {1,1,1,0,0,0,0,0};
char s2[] = {0,0,1,1,1,0,0,0};
char s3[] = {0,0,0,0,1,1,1,0};
char phase=0;

void StepperOff() {
   S0=0;
   S1=0;
   S2=0;
   S3=0;
}

void SetPhase() {
    S0 = s0[phase];
    S1 = s1[phase];;
    S2 = s2[phase];;
    S3 = s3[phase];;
}

void SmallLeft(int i) {
    phase++;
    if(phase>7) phase = 0;
    Delay_us(i);
    SetPhase();

}

void SmallRight(int i) {
    if(phase==0) phase = 8;
    phase--;
    Delay_us(i);
    SetPhase();
}

void Left(int i) {
   int j;
//return;

   for(j=0; j<64; j++) SmallLeft(i);
}    

void Right(int i) {
   int j;
//return;

   for(j=0; j<64; j++) SmallRight(i);
}

